package com.example.graduationdesignbackend.controller;


import com.example.graduationdesignbackend.entity.ProductOrder;
import com.example.graduationdesignbackend.query.ProductOrderQuery;
import com.example.graduationdesignbackend.res.Res;
import com.example.graduationdesignbackend.service.IProductOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yuze
 * @since 2024-05-13
 */
@RestController
@RequestMapping("/productOrder")
public class ProductOrderController {
  @Autowired
  private IProductOrderService productOrderService;
  
  @GetMapping("/myPage")
  public Res getMyPage(ProductOrderQuery productOrderQuery){
    return Res.yuze(productOrderService.getMyProductOrderPage(productOrderQuery));
  }
  
  @GetMapping("/page")
  public Res getPage(ProductOrderQuery productOrderQuery){
    return Res.yuze(productOrderService.getProductOrderPage(productOrderQuery));
  }
  
  @GetMapping("/sale")
  public Res getSale(){
    return Res.yuze(productOrderService.getSalesVolume());
  }
  
  @PutMapping()
  public Res handleProductOrder(@RequestBody ProductOrder productOrder){
    return Res.yuze(productOrderService.handleProductOrder(productOrder.getId()));
  }
}
